package com.kongwg.java2;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

/**
 * @author kongwg
 * @create 2020-12-10 20:33
 */
public class CollectionTest {

    @Test
    public void test1(){
        Collection coll = new ArrayList();

        //add(Object e):将元素添加到集合coll中
        coll.add("AA");
        coll.add("BB");
        coll.add(123);
        coll.add(new Date());

        //size():获取元素的个数
        System.out.println(coll.size());

        //addAll()
        Collection coll1 = new ArrayList();
        coll1.add("CC");
        coll1.add(456);
        coll1.addAll(coll);

        System.out.println(coll1.size());
        System.out.println(coll1);

        //clear()
        coll.clear();

        //isEmpty()
        System.out.println(coll.isEmpty());
    }


}
